package org.moore.controller;

import org.moore.utils.Data;
import org.moore.view.GameFrame;
import org.moore.view.WelcomeJFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

// 欢迎界面游客跳转监听类
public class TouristButtonListener implements MouseListener {
    private final GameFrame gameFrame;
    private final WelcomeJFrame welcomeJFrame;

    public TouristButtonListener(GameFrame gameFrame, WelcomeJFrame welcomeJFrame) {
        this.gameFrame = gameFrame;
        this.welcomeJFrame = welcomeJFrame;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        // 创建一个新的字体对象
        Font newFont = new Font("宋体", Font.PLAIN, 18);
        // 设置所有的OptionPane字体
        UIManager.put("OptionPane.messageFont", newFont);
        UIManager.put("OptionPane.buttonFont", newFont);
        // 提示用户并禁用部分功能
        JOptionPane.showMessageDialog(welcomeJFrame, "使用游客登录，部分功能将不可用！");
        GameFrame.getGameBar().getRoadItem().setEnabled(false);
        GameFrame.getGameBar().getRankingListItem().setEnabled(false);
        gameFrame.setTitle("武侠消消乐【使用游客登录，部分功能将不可用】");
        gameFrame.setVisible(true);
        welcomeJFrame.setVisible(false);
        Data.TOURIST = true;
    }

    @Override
    public void mousePressed(MouseEvent e) {

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }
}
